package unit7;

import java.util.Scanner;

public class Test7 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(true) {
			System.out.println("请输入八位数【八个零表示结束】:");
			String LuckyNum=scanner.next();
			if ("00000000".equals(LuckyNum)) {
				System.out.println("再见，欢迎下次光临");
				break;
			}else {
				if (LuckyNum==null) {
					System.out.println("请您输入");
				}else {
					if (LuckyNum.length()==8) {
						boolean flag=true;
						for(int i=0;i<=LuckyNum.length()-1;i++) {
							char a=LuckyNum.charAt(i);
							if (a<'0'||a>'9') {
								
								flag=false;
								System.out.println("您输入了非法字母【请重新输入】");
								break;
							}
						}
						if (flag) {
							if (LuckyNum.charAt(0)=='0') {
								System.out.println("最高位是0，请重新输入！");
								continue;
							}
							long LuckNum=Long.parseLong(LuckyNum);
							int sum=0;
							do {
								sum+=LuckNum%10;
								LuckNum/=10;
							} while (LuckNum!=0);
							System.out.println("累加和是："+sum);
							if (sum%7==0) {
								System.out.println("恭喜您，中奖了");
							}else {
								System.out.println("未中奖！");
							}
						}
					}else {
						System.out.println("您输入的不是八位数，请继续输入");
						continue;
					}
				}
			}
			
		}

	}

}
